---
- name: ensure packages required for buildslave are installed (yum)
  yum: name={{ item }} state=latest enablerepo={{ extra_enablerepos }}
  with_items:
    - buildbot-slave
    - git
    - rpmlint
    - koji
    - bodhi-client
    - python-virtualenv
    - gcc
    - libcurl-devel
    - rpm-build
    - pylint
    - python-pep8
    - moreutils
  when: ansible_distribution_major_version|int < 22

- name: ensure packages required for buildslave are installed (dnf)
  dnf: name={{ item }} state=latest enablerepo={{ extra_enablerepos }}
  with_items:
    - buildbot-slave
    - git
    - rpmlint
    - koji
    - bodhi-client
    - python-virtualenv
    - gcc
    - libcurl-devel
    - rpm-build
    - pylint
    - python-pep8
    - moreutils
  when: ansible_distribution_major_version|int > 21 and ansible_cmdline.ostree is not defined

- name: add the buildslave user
  user: name=buildslave
  when: deployment_type == 'prod' or deployment_type == 'stg' or deployment_type == 'local'

- name: add buildslaves group
  group: name={{ slaves_group }}
  when: deployment_type == 'dev'

- name: add buildslave users
  user: name={{ item.user }} group={{ slaves_group }} home={{ item.home }}
  with_items: slaves
  when: deployment_type == 'dev'
